<template>
  <el-popover
    v-if="writeOffData"
    placement="bottom"
    width="400"
    trigger="hover">
    <div class="data-content">
      <div v-for="(item, index) in propArr" :key="index" class="data-item">
        <el-tooltip effect="dark" placement="top">
          <div slot="content" class="tc">
            {{ dataDetail(item) | moneyFilter }}
          </div>
          <span :class="[propNameArr[index].indexOf('最新') > 0 ? 'green' : '']" class="data">{{ dataDetail(item) | bigNumberZH }}</span>
        </el-tooltip>
        <div class="label">
          <div class="simple-label">{{ propNameArr[index] }}</div>
          <el-tooltip effect="dark" placement="top">
            <div slot="content" class="tc max-width-300">
              {{ tips[index] }}
            </div>
            <tipIcon is-diy class="icon-info" />
          </el-tooltip>
        </div>
      </div>
    </div>
    <div slot="reference" :class="{'mobile-more-btn': showMobilePage}" class="more-btn">
      更多
      <em class="el-icon-arrow-right icon-info" />
    </div>
  </el-popover>
</template>
<script>
import { bigNumberZH, moneyFilter } from '@/filters/number';
import orderDetail from '@/assets/order-detail.png';
export default {
  name: 'MoreAmountItem',
  filters: {
    bigNumberZH,
    moneyFilter
  },
  props: {
    writeOffData: {
      type: Object,
      default: () => null
    },
    propArr: {
      type: Array,
      default: () => []
    },
    propNameArr: {
      type: Array,
      default: () => []
    },
    tips: {
      type: Array,
      default: () => []
    },
    showMobilePage: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      orderDetail
    };
  },
  methods: {
    dataDetail(propName) {
      if (this.writeOffData && propName in this.writeOffData) {
        if (this.writeOffData[propName] !== 0) {
          return this.writeOffData[propName] / 100;
        } else {
          return this.writeOffData[propName];
        }
      }
      return '--';
    }
  }
};
</script>
<style lang="scss" scoped>
.more-btn {
  position: absolute;
  top: 12px;
  right: 10px;
  height: 18px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  cursor: pointer;
  font-size: 12px;
  color: #406EFF;
  font-weight: bold;
  img {
    margin-left: 5px;
    width: 16px;
    height: 16px;
  }
  &.mobile-more-btn {
    top: 8px;
    right: 5px;
  }
}
.data-content {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  margin-bottom: -10px;
  .data-item {
    display: flex;
    width: 50%;
    flex-direction: column;
    margin-bottom: 14px;
    align-items: center;
    .data {
      margin-bottom: 8px;
      color: #333;
      font-size: 18px;
      font-weight: bold;
      line-height: 24px;
    }
    .label {
      display: flex;
      margin-top: 2px;
      align-items: center;
      color: #999;
      font-size: 12px;
      line-height: 16px;
      .icon-info {
        margin-left: 4px;
        color: #999;
        font-size: 14px;
        &:hover {
          color: #406EFF;
        }
      }
    }
  }
}
.green {
  color: #31CC9C !important;
}
.max-width-300 {
  max-width: 300px;
}
</style>
